from django.newforms import ModelForm
from django import newforms as forms
from models import *

class UserProfileForm(ModelForm):
    username = forms.CharField(max_length = 30)
    password = forms.CharField(widget=forms.PasswordInput)
    password_comfirm = forms.CharField(widget=forms.PasswordInput)
    first_name = forms.CharField(max_length = 30)
    last_name = forms.CharField(max_length = 30)
    email = forms.EmailField()
    
    def clean(self):
        if self.cleaned_data.get('password') and self.cleaned_data.get('password_confirm') and self.cleaned_data['password'] != self.cleaned_data['password_confirm']:
            raise ValidationError(u'Please make sure your passwords match.')
        return self.cleaned_data

            
    
    class Meta:
        model = UserProfile
        fields = ('picture','signature','location','website')
